import unittest

from api.ihrm_emp_crud_api import IhrmEmpCRUDApi
from config import ID
from uilts.common_asserts import comm_asserts
from uilts.db_util import DBUtils
from uilts.get_token import get_login_token


class TestEmpQuery(unittest.TestCase):
    token = None
    @classmethod
    def setUpClass(cls):
        cls.token = get_login_token()

    def setUp(self):
        if DBUtils.select_one_dblist(F"select id from bs_user where id = '{ID}';"):
            DBUtils.uid_dblist(F"delete from bs_user where id = '{ID}'")
        else:
            DBUtils.uid_dblist(F"insert into bs_user(id, mobile, username) values('{ID}', '18571747410', 'kit')")

    def tearDown(self):
        DBUtils.uid_dblist(F"delete from bs_user where id = '{ID}'")

    def test_query_emp(self):
        resp = IhrmEmpCRUDApi.query_emp(ID, self.token)
        print(resp.json())
        comm_asserts(self, resp, 200, True, 10000, "操作成功")